package com.lianniu.web.seller.controller;

import com.lianniu.web.base.BaseResult;
import com.lianniu.web.seller.service.ISupplyRegisterService;
import com.lianniu.web.seller.vo.Supply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017-05-11.
 */
@Controller
@RequestMapping("/rest/supply/personal")
public class SupplyPersonalRestController {

    @Autowired
    private ISupplyRegisterService registerService;

    @RequestMapping("/supplyinfo")
    @ResponseBody
    public BaseResult getSupply(String userId) {
        return registerService.selectByUserId(userId);
    }

    @RequestMapping("/updateWechat")
    @ResponseBody
    public BaseResult updateWechat(String wechat,String supplyId){
        Supply supply = new Supply();
        supply.setWeixin(wechat);
        supply.setSupplyid(Long.valueOf(supplyId));
        registerService.updateByPrimaryKeySelective(supply);
        supply.setSupplyid(Long.valueOf(supplyId));
        return BaseResult.success();
    }

    @RequestMapping("updateCompName")
    @ResponseBody
    public BaseResult updateCompName(String compName,String supplyId)
    {
        Supply supply = new Supply();
        supply.setCompname(compName);
        supply.setSupplyid(Long.valueOf(supplyId));
        registerService.updateByPrimaryKeySelective(supply);
        return BaseResult.success();
    }

    @RequestMapping("/updateMainProduct")
    @ResponseBody
    public BaseResult updateMainProduct(String mainProduct,String supplyId)
    {
        Supply supply = new Supply();
        supply.setMainProduct(mainProduct);
        supply.setSupplyid(Long.valueOf(supplyId));
        registerService.updateByPrimaryKeySelective(supply);
        return BaseResult.success();
    }

    @RequestMapping("/updateSupplyName")
    @ResponseBody
    public BaseResult updateSupplyName(String supplyName,String supplyId)
    {
        Supply supply = new Supply();
        supply.setSupplyname(supplyName);
        supply.setSupplyid(Long.valueOf(supplyId));
        registerService.updateByPrimaryKeySelective(supply);
        return BaseResult.success();
    }

    @RequestMapping("/updateAddress")
    @ResponseBody
    public BaseResult updateAddress(Supply supply) {

        registerService.updateByPrimaryKeySelective(supply);
        return BaseResult.success();
    }
}
